﻿#include "param.h"

//注意：静态变量在类定义中只是向编译器声明，并未实际分配内存，需要在类外进行定义分配内存。
/*特殊参数*/
int Param::qrcode_to_mid;
int Param::agv_id;
QString Param::agv_ip;
int Param::agv_sys_data_port;
int Param::agv_sys_msg_port;
/*agv的物理参数*/
double Param::wheel_radius;
double Param::agv_radius;
QList<Param::IpAndPort> Param::sys_ip_and_port;  //业务调度的IP和端口
QString Param::sys_pose_ip;
int Param::sys_pose_port;
int Param::SysCommunicationFrequency;
int Param::SysPoseCommunicationFrequency;
int Param::lower_power;
double Param::enter_angle_limit;
int Param::lift_over_timer;
float Param::Fork_Min_Low_limit;
float Param::Fork_Low_limit;
float Param::Fork_Height_limit;
float Param::Fork_Max_Height_limit;
float Param::Lift_Pos_Tolerance;

/*navigation调节参数*/
int Param::distance_precision;
double Param::radian_precision;
int Param::horizontal_precision;
int Param::speed_up_unit;
int Param::max_speed_limit;
int Param::high_precision_speed;
int Param::max_speed;
int Param::max_speed_2;
int Param::mid_speed;
int Param::min_speed;
int Param::ready_speed;
int Param::obstacle_speed;
int Param::predict_time;
int Param::turn_degreee_dis;
double Param::coor_min_speed_kp;
double Param::coor_min_speed_ki;
double Param::coor_min_speed_kd;
double Param::coor_min_speed_integral_saturation;
double Param::coor_min_speed_adjust_limit;
double Param::coor_min_speed_gamma_r;
uint Param::ready_delay_ms;
uint Param::tracing_delay_ms;
uint Param::adjust_delay_ms;
int Param::dis_dec_bais;
int Param::kMinGammaDistance;
int Param::min_distance_limit;
int Param::mid_distance_limit;
int Param::max_distance_limit;
int Param::slow_down_dis;
int Param::close_obstacle_dis;
int Param::slam_obs_timer;
int Param::log_timer;
int Param::reset_obs_stop_timer;
int Param::change_obs_timer;
int Param::qrcode_mode_obs_switch;
int Param::qrcode_mode_default_front;
int Param::qrcode_mode_default_back;
int Param::slam_mode_default_max;
int Param::slam_mode_default_min;
int Param::auto_back_timer;
int Param::next_route_timer;
int Param::go_on_check_qrcode_timer;
int Param::lose_qrcode_dis;
int Param::lose_qrcode_timer;
int Param::max_point2line_to_around;
int Param::on_the_route_dis_limit;
int Param::close_obs_left;  // UDATE 221027添加左右避障开关
int Param::close_obs_right;
int Param::arrive_signal_open_close;
/*电机控制参数*/
double Param::jog_acc;                 //驱动器速度模式下的加速度； 单位：rps2 ； “注意：是电机的加减速不是轮子的加减速”
double Param::jog_dec;                 //同上意思
double Param::dock_acc;                //对接模式的加速度
double Param::dock_dec;                //
double Param::nomal_acc;               //举升旋转的加速度
double Param::nomal_dec;               //
double Param::reduction_radio;         //电机轮子的减速比
int Param::pulse_per_round;            //电机转一圈的脉冲数
int Param::Fork_Veer_pulse_per_round;  //叉车角度电机转一圈的脉冲数
double Param::length_per_pulse;        //每个脉冲轮子走的距离
int Param::left_direction;
int Param::right_direction;
int Param::lift_speed;                           // rpm
int Param::turn_speed;                           // rpm
                                                 /************单舵轮叉车电机参数***********/
int Param::pos_mode_speed;                       //舵轮转角转速 rmp
int Param::pos_mode_acc;                         // 转角加速度 rps^2
int Param::pos_mode_dec;                         // 转角减速度 rps^2
int Param::Zero_Pulse;                           //电机原点脉冲数值
int Param::pulse_per;                            //电机一圈脉冲数值
double Param::Veer_Wheel_Speed_Reduction_Radio;  //转角电机减速比
double Param::Walk_Wheel_Speed_Reduction_Radio;  //直行电机减速比
///////////////////////////////////////////
double Param::lift_length_per_pulse;  //升降电机每个脉冲行程距离 单位puls/mm
double Param::turn_rad_per_pulse;     //旋转电机每个脉冲旋转角度 单位puls/°
int Param::lift_origin_puls_count;    //升降原点脉冲计数 单位：脉冲数 （绝对值编码器使用）
int Param::turn_origin_puls_count;    //旋转原点脉冲计数 单位：脉冲数 （绝对值编码器使用）
double Param::speed_change_k;         //步科电机转换速度系数
double Param::acc_change_k;           //步科电机转换加减速度系数
double Param::lift_speed_change_k;    //步科举升电机转换速度系数
double Param::lift_acc_change_k;      //步科举升电机转换加减速度系数
/*串口*/
QString Param::IoControl_port_name;
QString Param::qrcode_port_name;
int Param::IoControl_baud_rate;
int Param::qrcode_baud_rate;
QString Param::battery_port_name;
int Param::battery_baud_rate;
/*二维码*/
QList<Station*> Param::qrcode_station_list;
int Param::qrcode_tag_num;
int Param::qrcode_tag_distance;
int Param::qrcode_tag_id_max_limit;

//注意：静态变量在类定义中只是向编译器声明，并未实际分配内存，需要在类外进行定义分配内存。

/**
 * @brief Param::readParam 读取ini文件中的参数，把其更新到Param类中的静态成员变量中
 */
void Param::readParam() {
  /*特殊参数*/
  qDebug() << "Param::readParam()";
  QSettings special_param("./ini/SpecialParam.ini", QSettings::IniFormat);
  qDebug() << "Param::readParam() special_param.fileName():" << special_param.fileName();
  special_param.setIniCodec(QTextCodec::codecForName("UTF-8"));
  special_param.beginGroup("SPECIAL");
  qrcode_to_mid = special_param.value("QRCODE_TO_MID", 0).toInt();
  agv_id = special_param.value("AGV_ID", 0).toInt();
  QString get_agv_ip = special_param.value("AGV_IP_PORT").toStringList().at(0);
  QString get_agv_sys_data_port = special_param.value("AGV_IP_PORT").toStringList().at(1);
  QString get_agv_sys_msg_port = special_param.value("AGV_IP_PORT").toStringList().at(2);
  qDebug() << "agv_ip:" << get_agv_ip;
  qDebug() << "agv_sys_data_port:" << get_agv_sys_data_port;
  qDebug() << "agv_sys_msg_port:" << get_agv_sys_msg_port;
  agv_ip = get_agv_ip.trimmed();
  agv_sys_data_port = get_agv_sys_data_port.trimmed().toInt();
  agv_sys_msg_port = get_agv_sys_msg_port.trimmed().toInt();
  special_param.endGroup();

  /*agv的物理参数*/
  qDebug() << "Param::agv的物理参数()";
  QSettings agv_setting("./ini/AgvParam.ini", QSettings::IniFormat);
  agv_setting.setIniCodec(QTextCodec::codecForName("UTF-8"));
  agv_setting.beginGroup("AGV");
  wheel_radius = agv_setting.value("WHEEL_RADIUS", 0).toDouble();
  agv_radius = agv_setting.value("AGV_RADIUS", 0).toDouble();

  // UPDATE 2022.07.28 加入多个调度IP
  QStringList demo = agv_setting.value("SYS_IP_PORT").toStringList();
  sys_ip_and_port.clear();
  if (demo.size() >= 2) {
    int j = 0;
    for (int i = 0; i < demo.size() / 2; i++) {
      IpAndPort ip_and_port;
      ip_and_port.ip = demo.at(j++).trimmed();
      ip_and_port.port = demo.at(j++).trimmed().toInt();
      sys_ip_and_port.append(ip_and_port);
    }
  }
  SysCommunicationFrequency = agv_setting.value("SysCommunicationFrequency", 500).toInt();

  QString get_sys_pose_ip = agv_setting.value("SYS_POSE_IP_PORT").toStringList().at(0);
  QString get_sys_pose_port = agv_setting.value("SYS_POSE_IP_PORT").toStringList().at(1);
  sys_pose_ip = get_sys_pose_ip.trimmed();
  sys_pose_port = get_sys_pose_port.trimmed().toInt();
  SysPoseCommunicationFrequency = agv_setting.value("SysPoseCommunicationFrequency", 500).toInt();
  lower_power = agv_setting.value("LOWER_POWER", 0).toInt();
  enter_angle_limit = agv_setting.value("ENTER_ANGLE_LIMIT", 0).toDouble();
  lift_over_timer = agv_setting.value("LIFT_OVER_TIMER", 0).toInt();
  Fork_Min_Low_limit = agv_setting.value("FORK_MIN_LOW_LIMIT", 0).toFloat();
  Fork_Low_limit = agv_setting.value("FORK_LOW_LIMIT", 0).toFloat();
  Fork_Height_limit = agv_setting.value("FORK_HEIGHT_LIMIT", 0).toFloat();
  Fork_Max_Height_limit = agv_setting.value("FORK_MAX_HEIGHT_LIMIT", 0).toFloat();
  Lift_Pos_Tolerance = agv_setting.value("LIFT_POS_TOLERANCE", 0).toFloat();

  agv_setting.endGroup();

  /*navigation调节参数*/
  QSettings navi_setting("./ini/NaviParam.ini", QSettings::IniFormat);
  navi_setting.setIniCodec(QTextCodec::codecForName("UTF-8"));
  navi_setting.beginGroup("NAVIGATION");
  distance_precision = navi_setting.value("DISTANCE_PRECISION", 0).toInt();
  radian_precision = navi_setting.value("RADIAN_PRECISION", 0.017).toDouble();
  horizontal_precision = navi_setting.value("HORIZONTAL_PRECISION", 10).toInt();
  speed_up_unit = navi_setting.value("SPEED_UP_UNIT", 0).toInt();
  max_speed_limit = navi_setting.value("MAX_SPEED_LIMIT", 0).toInt();
  high_precision_speed = navi_setting.value("HIGH_PRECISION_SPEED", 0).toInt();
  max_speed = navi_setting.value("MAX_SPEED", 0).toInt();
  max_speed_2 = navi_setting.value("MAX_SPEED_2", 0).toInt();
  mid_speed = navi_setting.value("MID_SPEED", 0).toInt();
  min_speed = navi_setting.value("MIN_SPEED", 0).toInt();
  ready_speed = navi_setting.value("READY_SPEED", 5).toInt();
  obstacle_speed = navi_setting.value("OBSTACLE_SPEED", 5).toInt();
  predict_time = navi_setting.value("PREDICT_TIME", 50).toInt();
  turn_degreee_dis = navi_setting.value("TURN_DEGREE_DIS", 760).toInt();
  coor_min_speed_kp = navi_setting.value("COOR_MIN_SPEED_KP", 0).toDouble();
  coor_min_speed_ki = navi_setting.value("COOR_MIN_SPEED_KI", 0).toDouble();
  coor_min_speed_kd = navi_setting.value("COOR_MIN_SPEED_KD", 0).toDouble();
  coor_min_speed_integral_saturation = navi_setting.value("COOR_MIN_SPEED_INTEGRAL_SATURATION", 99999999).toDouble();
  coor_min_speed_adjust_limit = navi_setting.value("COOR_MIN_SPEED_ADJUST_LIMIT", 99999999).toDouble();
  coor_min_speed_gamma_r = navi_setting.value("COOR_MIN_SPEED_GAMMA_R", 400).toDouble();
  ready_delay_ms = navi_setting.value("READY_DELAY_MS", 1000).toUInt();
  tracing_delay_ms = navi_setting.value("TRACING_DELAY_MS", 1000).toUInt();
  adjust_delay_ms = navi_setting.value("ADJUST_DELAY_MS", 1000).toUInt();
  dis_dec_bais = navi_setting.value("DIS_DEC_BAIS", 1000).toInt();
  kMinGammaDistance = navi_setting.value("KMINGAMMADISTANCE", 600).toInt();
  min_distance_limit = navi_setting.value("MIN_DISTANCE_LIMIT", 0).toInt();
  mid_distance_limit = navi_setting.value("MID_DISTANCE_LIMIT", 0).toInt();
  max_distance_limit = navi_setting.value("MAX_DISTANCE_LIMIT", 0).toInt();
  slow_down_dis = navi_setting.value("SLOW_DOWN_DIS", 0).toInt();
  close_obstacle_dis = navi_setting.value("CLOSE_OBSTACLE_DIS", 400).toInt();
  slam_obs_timer = navi_setting.value("SLAMOBS_TIMER", 0).toInt();
  log_timer = navi_setting.value("LOG_TIMER", 500).toInt();
  reset_obs_stop_timer = navi_setting.value("RESET_OBS_STOP_TIMER", 0).toInt();
  qrcode_mode_obs_switch = navi_setting.value("QRCODE_MODE_OBS_SWITCH", 1).toInt();
  qrcode_mode_default_front = navi_setting.value("QRCODE_MODE_DEFAULT_FRONT", 1).toInt();
  qrcode_mode_default_back = navi_setting.value("QRCODE_MODE_DEFAULT_BACK", 1).toInt();
  change_obs_timer = navi_setting.value("CHANGE_OBS_TIMER", 0).toInt();
  slam_mode_default_max = navi_setting.value("SLAM_MODE_DEFAULT_MAX", 3).toInt();
  slam_mode_default_min = navi_setting.value("SLAM_MODE_DEFAULT_MIN", 2).toInt();
  auto_back_timer = navi_setting.value("ATUO_BACK_TIMER", 0).toInt();
  next_route_timer = navi_setting.value("NEXT_ROUTE_TIMER", 0).toInt();
  go_on_check_qrcode_timer = navi_setting.value("GO_ON_CHECK_QRCODE_TIMER", 0).toInt();
  lose_qrcode_dis = navi_setting.value("LOSE_QRCODE_DIS", 0).toInt();
  lose_qrcode_timer = navi_setting.value("LOSE_QRCODE_TIMER", 0).toInt();
  max_point2line_to_around = navi_setting.value("MAX_POINT2LINE_TO_AROUND", 0).toInt();
  on_the_route_dis_limit = navi_setting.value("ON_THE_ROUTE_DIS_LIMIT", 2000).toInt();
  close_obs_left = navi_setting.value("CLOSE_OBS_LEFT", 1).toInt();  // UDATE 221027添加左右避障开关
  close_obs_right = navi_setting.value("CLOSE_OBS_RIGHT", 1).toInt();
  arrive_signal_open_close = navi_setting.value("ARRIVE_SIGNAL_OPEN_CLOSE", 1).toInt();
  navi_setting.endGroup();

  /*电机控制参数*/
  QSettings motion_setting("./ini/MotionParam.ini", QSettings::IniFormat);
  motion_setting.setIniCodec(QTextCodec::codecForName("UTF-8"));
  motion_setting.beginGroup("MOTION CONTROL");
  jog_acc = motion_setting.value("JOG_ACC", 50).toDouble();
  jog_dec = motion_setting.value("JOG_DEC", 50).toDouble();
  dock_acc = motion_setting.value("DOCK_ACC", 50).toDouble();
  dock_dec = motion_setting.value("DOCK_DEC", 50).toDouble();
  nomal_acc = motion_setting.value("NOMAL_ACC", 50).toDouble();
  nomal_dec = motion_setting.value("NOMAL_DEC", 50).toDouble();
  reduction_radio = motion_setting.value("REDUCTION_RADIO", 28).toDouble();
  pulse_per_round = motion_setting.value("PULSE_PER_ROUND", 10000).toInt();
  length_per_pulse = 2 * M_PI * wheel_radius / (pulse_per_round * reduction_radio);
  Fork_Veer_pulse_per_round = motion_setting.value("PULSE_PER_ROUND", 131072).toInt();
  left_direction = motion_setting.value("LEFT_DIRECTION", 1).toInt();
  right_direction = motion_setting.value("RIGHT_DIRECTION", -1).toInt();
  lift_speed = motion_setting.value("LIFT_SPEED", 100).toInt();
  turn_speed = motion_setting.value("TURN_SPEED", 100).toInt();
  lift_length_per_pulse = motion_setting.value("LIFT_LENGTH_PER_PULSE", 0.01).toDouble();
  turn_rad_per_pulse = motion_setting.value("TURN_RAD_PER_PULSE", 0.01).toDouble();
  lift_origin_puls_count = motion_setting.value("LIFT_ORIGIN_PULS_COUNT", 100).toInt();
  turn_origin_puls_count = motion_setting.value("TURN_ORIGIN_PULS_COUNT", 100).toInt();
  speed_change_k = motion_setting.value("SPEED_CHANGE_K", 0.01).toDouble();
  acc_change_k = motion_setting.value("ACC_CHANGE_K", 0.01).toDouble();
  lift_speed_change_k = motion_setting.value("LIFT_SPEED_CHANGE_K", 0.01).toDouble();
  lift_acc_change_k = motion_setting.value("LIFT_ACC_CHANGE_K", 0.01).toDouble();
  /************单舵轮叉车电机参数***********/
  pos_mode_speed = motion_setting.value("pos_mode_speed", 1280).toInt();
  pos_mode_acc = motion_setting.value("pos_mode_acc", 900).toInt();
  pos_mode_dec = motion_setting.value("pos_mode_dec", 900).toInt();
  Zero_Pulse = motion_setting.value("Zero_Pulse", -2407666).toInt();
  pulse_per = motion_setting.value("pulse_per", 131072).toInt();
  Veer_Wheel_Speed_Reduction_Radio = motion_setting.value("Veer_Wheel_Speed_Reduction_Radio", 64).toInt();
  Walk_Wheel_Speed_Reduction_Radio = motion_setting.value("Walk_Wheel_Speed_Reduction_Radio", 27.84).toInt();
  motion_setting.endGroup();

  /*串口*/
  QSettings com_setting("./ini/ComParam.ini", QSettings::IniFormat);
  com_setting.setIniCodec(QTextCodec::codecForName("UTF-8"));
  com_setting.beginGroup("COM");
  for (const auto& data : com_setting.childKeys()) {
    QString com_port_name = com_setting.value(data).toStringList().at(0);
    QString com_baud_rate = com_setting.value(data).toStringList().at(1);
    if (data == QString("IOCONTROL")) {
      IoControl_port_name = com_port_name.trimmed();
      IoControl_baud_rate = com_baud_rate.trimmed().toInt();
    } else if (data == QString("QRCODE")) {
      qrcode_port_name = com_port_name.trimmed();
      qrcode_baud_rate = com_baud_rate.trimmed().toInt();
    } else if (data == QString("BATTERY")) {
      battery_port_name = com_port_name.trimmed();
      battery_baud_rate = com_baud_rate.trimmed().toInt();
    }
  }
  com_setting.endGroup();
  /***************************QRCODE LIST*********************************/
  QSettings qrcode_setting("./ini/QrcodeParam.ini", QSettings::IniFormat);
  qrcode_setting.setIniCodec(QTextCodec::codecForName("UTF-8"));

  qrcode_setting.beginGroup("QRCODE LIST");
  //设置二维码坐标。先清除，防止参数重置时没把以前的删掉
  if (!qrcode_station_list.isEmpty()) {
    for (auto station : qrcode_station_list) { delete station; }
    qrcode_station_list.clear();
  }
  //默认会构造一条位置数据明显错误的二维码带
  qrcode_tag_num = qrcode_setting.value("QRCODE_TAG_NUM", 255).toInt();
  qrcode_tag_distance = qrcode_setting.value("QRCODE_TAG_DISTANCE", 0).toInt();
  qrcode_tag_id_max_limit = qrcode_setting.value("QRCODE_TAG_ID_MAX_LIMIT", 19).toInt();
  for (int i = 0; i < qrcode_tag_num; i++) {
    Station* station = new Station;
    station->id = i;
    if (i <= 9) {  //构建0-9
      station->point = {0, static_cast<double>(i * qrcode_tag_distance)};
    } else if (i >= 10 && i <= 19) {  //构建10-19
      station->point = {0, static_cast<double>((i - 10) * qrcode_tag_distance)};
    } else {
      station->point = {0, 0};
    }
    qrcode_station_list.append(station);
  }
  foreach (QString data, qrcode_setting.childKeys()) {
    if (data.left(3) == QString("TAG")) {
      int tagid = data.midRef(3, 3).toInt();
      QString coordinate_x = qrcode_setting.value(data).toStringList().at(0);
      QString coordinate_y = qrcode_setting.value(data).toStringList().at(1);
      double x = coordinate_x.trimmed().toInt();
      double y = coordinate_y.trimmed().toInt();
      qrcode_station_list.at(tagid)->point = {x, y};
      Q_ASSERT(qrcode_station_list.at(tagid));
    }
  }
  qrcode_setting.endGroup();
}

void Param::writeParam() {}

void Param::printParam() {
  /**********************************************************************************/
  qDebug() << "----------------------------Read Param----------------------------";
  qDebug() << "----------------------------特殊参数-------------------------";
  qDebug() << "qrcode_to_mid =" << qrcode_to_mid;
  qDebug() << "agv_id =" << agv_id;
  qDebug() << "agv_ip =" << agv_ip;
  qDebug() << "agv_sys_data_port =" << agv_sys_data_port;
  qDebug() << "agv_sys_msg_port =" << agv_sys_msg_port;
  qDebug() << "----------------------------agv的物理参数-------------------------";
  qDebug() << "wheel_radius =" << wheel_radius;
  qDebug() << "agv_radius =" << agv_radius;
  foreach (IpAndPort demo, sys_ip_and_port) { qDebug() << "sys_ip:" << demo.ip << "sys_port:" << demo.port; }
  qDebug() << "sys_pose_ip =" << sys_pose_ip;
  qDebug() << "sys_pose_port =" << sys_pose_port;
  qDebug() << "SysCommunicationFrequency =" << SysCommunicationFrequency;
  qDebug() << "SysPoseCommunicationFrequency =" << SysPoseCommunicationFrequency;
  qDebug() << "lower_power =" << lower_power;
   qDebug() << "enter_angle_limit =" << enter_angle_limit;
  qDebug() << "transmit_over_timer =" << lift_over_timer;
  qDebug() << "Fork_Min_Low_limit =" << Fork_Min_Low_limit;
  qDebug() << "Fork_Low_limit =" << Fork_Low_limit;
  qDebug() << "Fork_Height_limit =" << Fork_Height_limit;
  qDebug() << "Fork_Max_Height_limit =" << Fork_Max_Height_limit;
  qDebug() << "Lift_Pos_Tolerance =" << Lift_Pos_Tolerance;

  qDebug() << "----------------------------navigation调节参数---------------------";
  qDebug() << "distance_precision =" << distance_precision;
  qDebug() << "radian_precision =" << radian_precision;
  qDebug() << "horizontal_precision =" << horizontal_precision;
  qDebug() << "speed_up_unit =" << speed_up_unit;
  qDebug() << "max_speed_limit =" << max_speed_limit;
  qDebug() << "high_precision_speed =" << high_precision_speed;
  qDebug() << "max_speed =" << max_speed;
  qDebug() << "max_speed_2 =" << max_speed_2;
  qDebug() << "mid_speed =" << mid_speed;
  qDebug() << "min_speed =" << min_speed;
  qDebug() << "ready_speed =" << ready_speed;
  qDebug() << "obstacle_speed =" << obstacle_speed;
  qDebug() << "predict_time =" << predict_time;
  qDebug() << "turn_degreee_dis =" << turn_degreee_dis;
  qDebug() << "coor_min_speed_kp =" << coor_min_speed_kp;
  qDebug() << "coor_min_speed_ki =" << coor_min_speed_ki;
  qDebug() << "coor_min_speed_kd =" << coor_min_speed_kd;
  qDebug() << "coor_min_speed_integral_saturation =" << coor_min_speed_integral_saturation;
  qDebug() << "coor_min_speed_adjust_limit =" << coor_min_speed_adjust_limit;
  qDebug() << "coor_min_speed_gamma_r =" << coor_min_speed_gamma_r;
  qDebug() << "ready_delay_ms =" << ready_delay_ms;
  qDebug() << "tracing_delay_ms =" << tracing_delay_ms;
  qDebug() << "adjust_delay_ms =" << adjust_delay_ms;
  qDebug() << "dis_dec_bais =" << dis_dec_bais;
  qDebug() << "kMinGammaDistance =" << kMinGammaDistance;
  qDebug() << "min_distance_limit =" << min_distance_limit;
  qDebug() << "mid_distance_limit =" << mid_distance_limit;
  qDebug() << "max_distance_limit =" << max_distance_limit;
  qDebug() << "slow_down_dis =" << slow_down_dis;
  qDebug() << "close_obstacle_dis =" << close_obstacle_dis;
  qDebug() << "slam_obs_timer =" << slam_obs_timer;
  qDebug() << "log_timer =" << log_timer;
  qDebug() << "reset_obs_stop_timer =" << reset_obs_stop_timer;
  qDebug() << "change_obs_timer =" << change_obs_timer;
  qDebug() << "qrcode_mode_obs_switch =" << qrcode_mode_obs_switch;
  qDebug() << "qrcode_mode_default_front =" << qrcode_mode_default_front;
  qDebug() << "qrcode_mode_default_back =" << qrcode_mode_default_back;
  qDebug() << "slam_mode_default_max =" << slam_mode_default_max;
  qDebug() << "slam_mode_default_min =" << slam_mode_default_min;
  qDebug() << "auto_back_timer =" << auto_back_timer;
  qDebug() << "next_route_timer =" << next_route_timer;
  qDebug() << "go_on_check_qrcode_timer =" << go_on_check_qrcode_timer;
  qDebug() << "lose_qrcode_dis =" << lose_qrcode_dis;
  qDebug() << "lose_qrcode_timer =" << lose_qrcode_timer;
  qDebug() << "max_point2line_to_around =" << max_point2line_to_around;
  qDebug() << "on_the_route_dis_limit =" << on_the_route_dis_limit;
  qDebug() << "close_obs_left =" << close_obs_left;
  qDebug() << "close_obs_right =" << close_obs_right;
  qDebug() << "arrive_signal_open_close" << arrive_signal_open_close;
  qDebug() << "----------------------------电机控制参数----------------------------";
  qDebug() << "jog_acc =" << jog_acc;
  qDebug() << "jog_dec =" << jog_dec;
  qDebug() << "dock_acc =" << dock_acc;
  qDebug() << "dock_dec =" << dock_dec;
  qDebug() << "nomal_acc =" << nomal_acc;
  qDebug() << "nomal_dec =" << nomal_dec;
  qDebug() << "reduction_radio =" << reduction_radio;
  qDebug() << "pulse_per_round =" << pulse_per_round;
  qDebug() << "Fork_Veer_pulse_per_round =" << Fork_Veer_pulse_per_round;
  qDebug() << "length_per_pulse =" << length_per_pulse;
  qDebug() << "left_direction =" << left_direction;
  qDebug() << "right_direction =" << right_direction;
  qDebug() << "lift_speed =" << lift_speed;
  qDebug() << "lift_length_per_pulse =" << lift_length_per_pulse;
  qDebug() << "turn_rad_per_pulse =" << turn_rad_per_pulse;
  qDebug() << "lift_origin_puls_count =" << lift_origin_puls_count;
  qDebug() << "turn_origin_puls_count =" << turn_origin_puls_count;
  qDebug() << "speed_change_k =" << speed_change_k;
  qDebug() << "acc_change_k =" << acc_change_k;
  qDebug() << "lift_speed_change_k =" << lift_speed_change_k;
  qDebug() << "lift_acc_change_k =" << lift_acc_change_k;
  qDebug() << "pos_mode_speed =" << pos_mode_speed;
  qDebug() << "pos_mode_acc =" << pos_mode_acc;
  qDebug() << "pos_mode_dec =" << pos_mode_dec;
  qDebug() << "Zero_Pulse =" << Zero_Pulse;
  qDebug() << "pulse_per =" << pulse_per;
  qDebug() << "Veer_Wheel_Speed_Reduction_Radio =" << Veer_Wheel_Speed_Reduction_Radio;
  qDebug() << "Walk_Wheel_Speed_Reduction_Radio =" << Walk_Wheel_Speed_Reduction_Radio;
  qDebug() << "----------------------------串口----------------------------";
  qDebug() << "IoControl_port_name =" << IoControl_port_name;
  qDebug() << "IoControl_baud_rate =" << IoControl_baud_rate;
  qDebug() << "qrcode_port_name =" << qrcode_port_name;
  qDebug() << "qrcode_baud_rate =" << qrcode_baud_rate;
  qDebug() << "battery_port_name =" << battery_port_name;
  qDebug() << "battery_baud_rate =" << battery_baud_rate;
  qDebug() << "----------------------------二维码----------------------------";
  qDebug() << "qrcode_tag_num =" << qrcode_tag_num;
  qDebug() << "qrcode_tag_distance =" << qrcode_tag_distance;
  qDebug() << "qrcode_tag_id_max_limit =" << qrcode_tag_id_max_limit;
  for (auto station : qrcode_station_list) { qDebug() << *station; }
  qDebug() << "----------------------------Read Param----------------------------";
}

Param::Param(QObject* parent) : QObject(parent) {}

Param::~Param() {}
